package com.hdw.job.service;

import com.hdw.common.vo.PaginationVO;
import org.springframework.stereotype.Service;
import com.hdw.job.api.EtlGroupBatchService;
import com.hdw.job.mapper.EtlGroupBatchMapper;
import com.hdw.job.bean.model.EtlGroupBatch;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;

/**
 * etlGroupBatch服务实现类
 * Created by liujunlei on 2022/01/10.
 */
@Service
@Transactional
public class EtlGroupBatchServiceImpl implements EtlGroupBatchService{

    private static final Logger LOGGER = LoggerFactory.getLogger(EtlGroupBatchServiceImpl.class);

    @Autowired
    private EtlGroupBatchMapper etlGroupBatchMapper;

    @Override
    public int insert(EtlGroupBatch etlGroupBatch) {
        return etlGroupBatchMapper.insert(etlGroupBatch);
    }

    @Override
    public int insertSelective(EtlGroupBatch etlGroupBatch)  {
        return etlGroupBatchMapper.insertSelective(etlGroupBatch);
    }

    @Override
    public int deleteById(Long idGroupBatch)  {
        return etlGroupBatchMapper.deleteByPrimaryKey(idGroupBatch);
    }

    @Override
    public int updateByIdSelective(EtlGroupBatch etlGroupBatch)  {

        return etlGroupBatchMapper.updateByPrimaryKeySelective(etlGroupBatch);
    }

    @Override
    public int updateById(EtlGroupBatch etlGroupBatch)  {
        return etlGroupBatchMapper.updateByPrimaryKey(etlGroupBatch);
    }

    @Override
    public EtlGroupBatch getById(Long idGroupBatch)  {
        return etlGroupBatchMapper.selectByPrimaryKey(idGroupBatch);
    }

    @Override
    public List<EtlGroupBatch> findByModel(EtlGroupBatch etlGroupBatch)  {
        return etlGroupBatchMapper.findByModel(etlGroupBatch);
    }

    @Override
    public PaginationVO<EtlGroupBatch> findPageByModel(EtlGroupBatch etlGroupBatch, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum == null? 1 : pageNum, pageSize == null? 10 : pageSize);
        List<EtlGroupBatch> quesList = etlGroupBatchMapper.findByModel(etlGroupBatch);
        PageInfo<EtlGroupBatch> pageInfo = new PageInfo<>(quesList);
        PaginationVO<EtlGroupBatch> paginationVo = new PaginationVO(pageInfo.getTotal(), pageInfo.getList());
        return paginationVo;
    }

    @Override
    public List<EtlGroupBatch> findByModelWithOrder(EtlGroupBatch groupBatch) {
        return etlGroupBatchMapper.findByModelWithOrder(groupBatch);
    }
}
